package com.scedu.convert;

import com.scedu.domain.OrderMaster;
import com.scedu.dto.CartDTO;
import com.scedu.dto.OrderDTO;
import org.springframework.beans.BeanUtils;

import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;

/*
自定义转换器
 */
public class OrderMaster2OrderDTOConverter {
    public static OrderDTO convert(OrderMaster orderMaster){
        OrderDTO orderDTO=new OrderDTO();
        BeanUtils.copyProperties(orderMaster,orderDTO);
        return  orderDTO;

    }
    public  static List<OrderDTO> convert(List<OrderMaster> orderMasterList){
       List<OrderDTO> orderDTOList=orderMasterList.stream().map(e->
               convert(e)
                ).collect(Collectors.toList());
        return orderDTOList;
   }

    public  static List<OrderDTO> convertsc(List<OrderMaster> orderMasterList){
        List<OrderDTO> orderDTOList=new ArrayList<>();
        for (OrderMaster orderMaster:orderMasterList){
            OrderDTO orderDTO=convert(orderMaster);
        }
        return orderDTOList;
    }
}
